home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8890 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  904 b 

  1. Path: po.CWRU.Edu!mab22
  2. From: mab22@po.CWRU.Edu (Michael A. Balfour)
  3. Newsgroups: comp.lang.c
  4. Subject: Byte Orders and Char Sets?
  5. Date: 6 Mar 1996 19:56:49 GMT
  6. Organization: Case Western Reserve University, Cleveland, OH (USA)
  7. Message-ID: <4hkqm1$5dm@madeline.INS.CWRU.Edu>
  8. Reply-To: mab22@po.CWRU.Edu (Michael A. Balfour)
  9. NNTP-Posting-Host: nbsd.ins.cwru.edu
  10.  
  11.  
  12. Hi!
  13.  
  14. In the hopes of writing some portable code, I'm trying to 
  15. determine the byte order and character set that my program is
  16. compiled in.  Does anybody have a faster or cleaner way than
  17. this:
  18.  
  19. #define NativeCharSet() ((' '==0x40) ? EBCDIC_CHAR_SET : ASCII_CHAR_SET)
  20.  
  21. static unsigned short int nativeIntTest=0x0001;
  22. static char *nativeIntTest2=(char *)&nativeIntTest;
  23. #define NativeByteOrder() ((nativeIntTest2[0]==0x00) ? LITTLE_ENDIAN : BIG_ENDIAN)
  24.  
  25. (where the char sets and byte orders are also defined)
  26.  
  27. Thank you very much,
  28.  
  29. Mike Balfour
  30.